use prepared request to format payload before converting#271
use prepared request to format payload before converting#271p1c2u merged 3 commits intopython-openapi:masterfrom eyadgaran:master
Conversation
|
I ran into this same problem with 'json'. I have to prepare the request either way to send it, so it makes sense for the OpenAPI Request object to be created from that. |
|
I ran into problems trying to support requests with
edit: or does it hmmmm |
|
I was using this code successfully, but it stopped working after updated Edit: I had to add a deserializer: openapi_request_validator = RequestValidator(
openapi_spec,
custom_media_type_deserializers={
'application/x-www-form-urlencoded': lambda v: v if isinstance(v, dict) else dict(urllib.parse.parse_qsl(v)),
},
) |
Codecov Report
@@ Coverage Diff @@
## master #271 +/- ##
==========================================
+ Coverage 96.75% 96.77% +0.01%
==========================================
Files 122 122
Lines 2436 2448 +12
==========================================
+ Hits 2357 2369 +12
Misses 79 79
Continue to review full report at Codecov.
|
p1c2u
left a comment
There was a problem hiding this comment.
Added tests, removed py3 specific typing. LGTM
|
@eyadgaran thank you for the contribution. |
Use requests.PreparedRequest object to convert requests.Request into a formatted payload before converting into an OpenAPI request.
Fixes bug where one of the many requests.Request convenience methods (ex json) are used and payload is not stored in Request.data. Should also handle scenarios where persistent sessions have expected headers not applied to the request object until it is prepared and sent